package com.libui

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import com.libui.utils.FileChooserUtils

open class BaseActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        WindowCompat.setDecorFitsSystemWindows(window, false)

        WindowCompat
            .getInsetsController(window, window.decorView)
            .isAppearanceLightStatusBars = true

        WindowCompat
            .getInsetsController(window, window.decorView)
            .isAppearanceLightNavigationBars = true

        window.statusBarColor = getColor(android.R.color.transparent)

        window.navigationBarColor = getColor(android.R.color.white)

        ViewCompat.requestApplyInsets(window.decorView)
    }

    @Suppress("DEPRECATION")
    @Deprecated("Deprecated in Java", ReplaceWith("registerForActivityResult"))
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        if (!FileChooserUtils.instance.onActivityResult(requestCode, resultCode, data)) {
            super.onActivityResult(requestCode, resultCode, data)
        }
    }
}